package lib.checkrep;

public abstract class ArrayLongCheck {
  //bound array length
  public static boolean LengthInRange(long[] arr, int lower_bound, int upper_bound) {
    return arr.length >= lower_bound && arr.length <= upper_bound;
  }
  //bounds the elements of an array
  public static boolean ElementsInRange(long[] arr, long lower_bound, long upper_bound) {
    for (long i : arr) {
      if (i < lower_bound || i > upper_bound) return false;
    }
    return true;
  }
    //checks for any consecutive elements
  public static boolean ContainsConsecutiveIdenticalElements(long[] arr) {
    for (int i = 0; i < arr.length - 1; ++i) {
      if (arr[i] == arr[i+1]) return true;
    }
    return false;
  }

  //return true if array is sorted in ascending order
  public static boolean Ascending(long[] arr) {
    for (int i = 0; i < arr.length; ++i) for (int j = i+1; j < arr.length; ++j) {
      if (arr[i] > arr[j]) return false;
    }
    return true;
  }

  //return true if array is unique
  public static boolean Unique(long[] arr) {
    for (int i = 0; i < arr.length; ++i) for (int j = i+1; j < arr.length; ++j) {
      if (arr[i] == arr[j]) return false;
    }
    return true;
  }

  // return true if both arrays have no element in common
  public static boolean IsDisjoint(long[] arr1, long[] arr2) {
    for (int i = 0; i < arr1.length; ++i)
      for (int j = 0; j < arr2.length; ++j)
        if (arr1[i] == arr2[j]) return false;
    return true;
  }

  // return true if for each pair of elements in the array, one is a divisor
  // of the other
  public static boolean IsPairwiseDivides(long[] arr) {
    for (int i = 0; i < arr.length; ++i) {
      for (int j = 0; j < arr.length; ++j) {
        if (arr[i] % arr[j] != 0 && arr[j] % arr[i] != 0) {
          return false;
        }
      }
    }
    return true;
  }
};